package b.p.b;

import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
import android.view.View;
import androidx.recyclerview.widget.RecyclerView.z;
import java.util.ArrayList;
import java.util.List;

/* compiled from: DefaultItemAnimator */
public class m extends d0 {
    public static TimeInterpolator s;
    public ArrayList<z> h = new ArrayList();
    public ArrayList<z> i = new ArrayList();
    public ArrayList<b> j = new ArrayList();
    public ArrayList<a> k = new ArrayList();
    public ArrayList<ArrayList<z>> l = new ArrayList();
    public ArrayList<ArrayList<b>> m = new ArrayList();
    public ArrayList<ArrayList<a>> n = new ArrayList();
    public ArrayList<z> o = new ArrayList();
    public ArrayList<z> p = new ArrayList();
    public ArrayList<z> q = new ArrayList();
    public ArrayList<z> r = new ArrayList();

    /* compiled from: DefaultItemAnimator */
    public static class a {
        public z a;
        public z b;
        public int c;
        public int d;
        public int e;
        public int f;

        public a(z zVar, z zVar2, int i, int i2, int i3, int i4) {
            this.a = zVar;
            this.b = zVar2;
            this.c = i;
            this.d = i2;
            this.e = i3;
            this.f = i4;
        }

        public String toString() {
            StringBuilder g = c.b.a.a.a.g("ChangeInfo{oldHolder=");
            g.append(this.a);
            g.append(", newHolder=");
            g.append(this.b);
            g.append(", fromX=");
            g.append(this.c);
            g.append(", fromY=");
            g.append(this.d);
            g.append(", toX=");
            g.append(this.e);
            g.append(", toY=");
            g.append(this.f);
            g.append('}');
            return g.toString();
        }
    }

    /* compiled from: DefaultItemAnimator */
    public static class b {
        public z a;
        public int b;
        public int c;
        public int d;
        public int e;

        public b(z zVar, int i, int i2, int i3, int i4) {
            this.a = zVar;
            this.b = i;
            this.c = i2;
            this.d = i3;
            this.e = i4;
        }
    }

    public void e(z zVar) {
        ArrayList arrayList;
        View view = zVar.a;
        view.animate().cancel();
        int size = this.j.size();
        while (true) {
            size--;
            if (size < 0) {
                break;
            } else if (((b) this.j.get(size)).a == zVar) {
                view.setTranslationY(0.0f);
                view.setTranslationX(0.0f);
                c(zVar);
                this.j.remove(size);
            }
        }
        l(this.k, zVar);
        if (this.h.remove(zVar)) {
            view.setAlpha(1.0f);
            c(zVar);
        }
        if (this.i.remove(zVar)) {
            view.setAlpha(1.0f);
            c(zVar);
        }
        size = this.n.size();
        while (true) {
            size--;
            if (size < 0) {
                break;
            }
            arrayList = (ArrayList) this.n.get(size);
            l(arrayList, zVar);
            if (arrayList.isEmpty()) {
                this.n.remove(size);
            }
        }
        size = this.m.size();
        while (true) {
            size--;
            if (size < 0) {
                break;
            }
            arrayList = (ArrayList) this.m.get(size);
            int size2 = arrayList.size();
            while (true) {
                size2--;
                if (size2 < 0) {
                    break;
                } else if (((b) arrayList.get(size2)).a == zVar) {
                    view.setTranslationY(0.0f);
                    view.setTranslationX(0.0f);
                    c(zVar);
                    arrayList.remove(size2);
                    if (arrayList.isEmpty()) {
                        this.m.remove(size);
                    }
                }
            }
        }
        size = this.l.size();
        while (true) {
            size--;
            if (size >= 0) {
                ArrayList arrayList2 = (ArrayList) this.l.get(size);
                if (arrayList2.remove(zVar)) {
                    view.setAlpha(1.0f);
                    c(zVar);
                    if (arrayList2.isEmpty()) {
                        this.l.remove(size);
                    }
                }
            } else {
                this.q.remove(zVar);
                this.o.remove(zVar);
                this.r.remove(zVar);
                this.p.remove(zVar);
                k();
                return;
            }
        }
    }

    public void f() {
        a aVar;
        z zVar;
        int size = this.j.size();
        while (true) {
            size--;
            if (size < 0) {
                break;
            }
            b bVar = (b) this.j.get(size);
            View view = bVar.a.a;
            view.setTranslationY(0.0f);
            view.setTranslationX(0.0f);
            c(bVar.a);
            this.j.remove(size);
        }
        size = this.h.size();
        while (true) {
            size--;
            if (size < 0) {
                break;
            }
            c((z) this.h.get(size));
            this.h.remove(size);
        }
        size = this.i.size();
        while (true) {
            size--;
            if (size < 0) {
                break;
            }
            z zVar2 = (z) this.i.get(size);
            zVar2.a.setAlpha(1.0f);
            c(zVar2);
            this.i.remove(size);
        }
        size = this.k.size();
        while (true) {
            size--;
            if (size < 0) {
                break;
            }
            aVar = (a) this.k.get(size);
            zVar = aVar.a;
            if (zVar != null) {
                m(aVar, zVar);
            }
            zVar = aVar.b;
            if (zVar != null) {
                m(aVar, zVar);
            }
        }
        this.k.clear();
        if (g()) {
            ArrayList arrayList;
            size = this.m.size();
            while (true) {
                size--;
                if (size < 0) {
                    break;
                }
                ArrayList arrayList2 = (ArrayList) this.m.get(size);
                int size2 = arrayList2.size();
                while (true) {
                    size2--;
                    if (size2 < 0) {
                        break;
                    }
                    b bVar2 = (b) arrayList2.get(size2);
                    View view2 = bVar2.a.a;
                    view2.setTranslationY(0.0f);
                    view2.setTranslationX(0.0f);
                    c(bVar2.a);
                    arrayList2.remove(size2);
                    if (arrayList2.isEmpty()) {
                        this.m.remove(arrayList2);
                    }
                }
            }
            size = this.l.size();
            while (true) {
                size--;
                if (size < 0) {
                    break;
                }
                arrayList = (ArrayList) this.l.get(size);
                int size3 = arrayList.size();
                while (true) {
                    size3--;
                    if (size3 < 0) {
                        break;
                    }
                    zVar = (z) arrayList.get(size3);
                    zVar.a.setAlpha(1.0f);
                    c(zVar);
                    arrayList.remove(size3);
                    if (arrayList.isEmpty()) {
                        this.l.remove(arrayList);
                    }
                }
            }
            size = this.n.size();
            while (true) {
                size--;
                if (size >= 0) {
                    arrayList = (ArrayList) this.n.get(size);
                    int size4 = arrayList.size();
                    while (true) {
                        size4--;
                        if (size4 < 0) {
                            break;
                        }
                        aVar = (a) arrayList.get(size4);
                        zVar = aVar.a;
                        if (zVar != null) {
                            m(aVar, zVar);
                        }
                        zVar = aVar.b;
                        if (zVar != null) {
                            m(aVar, zVar);
                        }
                        if (arrayList.isEmpty()) {
                            this.n.remove(arrayList);
                        }
                    }
                } else {
                    j(this.q);
                    j(this.p);
                    j(this.o);
                    j(this.r);
                    d();
                    return;
                }
            }
        }
    }

    public boolean g() {
        return (this.i.isEmpty() && this.k.isEmpty() && this.j.isEmpty() && this.h.isEmpty() && this.p.isEmpty() && this.q.isEmpty() && this.o.isEmpty() && this.r.isEmpty() && this.m.isEmpty() && this.l.isEmpty() && this.n.isEmpty()) ? false : true;
    }

    public boolean i(z zVar, int i, int i2, int i3, int i4) {
        View view = zVar.a;
        int translationX = i + ((int) view.getTranslationX());
        int translationY = i2 + ((int) zVar.a.getTranslationY());
        n(zVar);
        i = i3 - translationX;
        i2 = i4 - translationY;
        if (i == 0 && i2 == 0) {
            c(zVar);
            return false;
        }
        if (i != 0) {
            view.setTranslationX((float) (-i));
        }
        if (i2 != 0) {
            view.setTranslationY((float) (-i2));
        }
        this.j.add(new b(zVar, translationX, translationY, i3, i4));
        return true;
    }

    public void j(List<z> list) {
        int size = list.size();
        while (true) {
            size--;
            if (size >= 0) {
                ((z) list.get(size)).a.animate().cancel();
            } else {
                return;
            }
        }
    }

    public void k() {
        if (!g()) {
            d();
        }
    }

    public final void l(List<a> list, z zVar) {
        int size = list.size();
        while (true) {
            size--;
            if (size >= 0) {
                a aVar = (a) list.get(size);
                if (m(aVar, zVar) && aVar.a == null && aVar.b == null) {
                    list.remove(aVar);
                }
            } else {
                return;
            }
        }
    }

    public final boolean m(a aVar, z zVar) {
        if (aVar.b == zVar) {
            aVar.b = null;
        } else if (aVar.a != zVar) {
            return false;
        } else {
            aVar.a = null;
        }
        zVar.a.setAlpha(1.0f);
        zVar.a.setTranslationX(0.0f);
        zVar.a.setTranslationY(0.0f);
        c(zVar);
        return true;
    }

    public final void n(z zVar) {
        if (s == null) {
            s = new ValueAnimator().getInterpolator();
        }
        zVar.a.animate().setInterpolator(s);
        e(zVar);
    }
}
